package ch02.graphics;

import java.awt.*;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;

import javax.swing.*;

@SuppressWarnings("serial")
public class FaceComponent extends JComponent
{
	public void paintComponent(Graphics g)
	{
		Graphics2D g2 = (Graphics2D) g;
		 
		//Draw ellipse
		Ellipse2D.Double head = new Ellipse2D.Double(5, 10, 100, 150);
		g2.draw(head);
		
		//Draw rectangle
		g2.setColor(Color.GREEN);
		Rectangle eye = new Rectangle(25,70,15,15);
		g2.draw(eye); //line only
		eye.translate(50, 0);
		g2.fill(eye); //fill
		
		//Draw line
		Line2D.Double mouth = new Line2D.Double(30, 110, 80, 110);
		g2.setColor(new Color(255, 34, 34));
		g2.draw(mouth);
		
		//Draw text
		g2.setColor(Color.BLUE);
		g2.drawString("Yo, World!", 5, 175);
		
	}

}
